class GameOver extends eui.Component implements eui.UIComponent {
	public constructor() {
		super();
		this.skinName = 'GameOverSkin';
	}

	protected partAdded(partName: string, instance: any): void {
		super.partAdded(partName, instance);
	}

	private look;
	private backindex;
	private winners;
	private over1;
	public gameover;
	private gameover1;
	private playagain;
	protected childrenCreated(): void {
		super.childrenCreated();
		// 查看排名按钮
		this.look.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
			this.winners = new Winners();
			this.winners.returnfan.once(egret.TouchEvent.TOUCH_TAP,()=>{
				this.removeChild(this.winners);
				this.winners = null;
			},this)
			this.addChild(this.winners);
		}, this)

		// 返回首页按钮
		this.backindex.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
			let index = new Index();
			this.addChild(index);
			index = null;
		}, this)

		//再玩一次
		this.playagain.addEventListener(egret.TouchEvent.TOUCH_TAP,()=>{
			SceneManager.getObj(this.stage).loadScene("game", bgRun)
		},this)

		// this.addEventListener(egret.Event.ENTER_FRAME, this.OnEvent, this);

		this.playAnimation(this.gameover1, true)
	}

	// private OnEvent(): void {
	// 	// 获奖名单
	// 	if (Winners.fanhui) {
	// 		Winners.fanhui = false;
	// 		this.removeChild(this.winners);
	// 		this.winners = null;
	// 	}
	// }

	//设置循环播放
	private playAnimation(target: egret.tween.TweenGroup, isLoop: boolean): void {
		if (isLoop) {
			for (var key in target.items) {
				target.items[key].props = { loop: true };
			}
		}
		target.play();
	}

}